// components/custom-checkbox/custom-checkbox.js
Component({
  /**
   * 组件的属性列表
   */
  options: {
    styleIsolation: "shared"
  },
  properties: {
    label: {
      type: String,
      value: ""
    },
    position: {
      type: String,
      value: ""
    },
    checked: {
      type: Boolean,
      value: false
    }
  },
  observers: {
    // 6 最好不要写箭头函数，里面没有this指向 会报错
    checked: function (obs) {
      this.setData({
        ischecked:  obs? JSON.parse(JSON.stringify(obs)) :false
      })
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    ischecked: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    updatachecked(e) {
      this.setData({
        ischecked: !this.data.ischecked
      })
      this.triggerEvent("changechecked", this.data.ischecked )
      // console.log("updatachecked", this.properties)
    },
    chem(obs) {
      this.setData({
        ischecked: obs
      })
    }

  }
})